package com.ea.common.annotation;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.ea.modular.model.sys.Log;
import com.ea.modular.service.sys.LogService;
import com.ea.modular.utils.sys.SpringUtil;

import java.util.TimerTask;

/**
 * 日志操作任务创建工厂
 *
 * @author jun
 */
public class LogTaskFactory {

    private static Logger logger = LoggerFactory.getLogger(LogManager.class);
   

   
    public static TimerTask saveTaskLog(final Log log) {
        return new TimerTask() {
            @Override
            public void run() {
                try {
                	
                	LogService logService = SpringUtil.getBean(LogService.class);
                	log.preInsert();
                	logService.insert(log);
            
                } catch (Exception e) {
                    logger.error("创建日志异常!", e);
                }
            }
        };
    }

}
